package com.model;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;

@Entity(name = "Roles")
public class Role implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private int id;
	
	private String name;
	
	private Set<Action> actions = new HashSet<Action>();

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public int getId() {
		return id;
	}
 
	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}

	public void setActions(Set<Action> actions) {
		this.actions = actions;
	}
	@ManyToMany(targetEntity = Action.class,fetch= FetchType.EAGER, cascade = CascadeType.REFRESH)
	public Set<Action> getActions() {
		return actions;
	}

	@Override
	public boolean equals(Object obj) {
		return super.equals(obj);
	}
	
	
}
